package aop.JDK_DynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyInvocationHandler implements InvocationHandler {

    private Object target;

    public MyInvocationHandler(Object target) {
        this.target = target;
    }


    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        //目标方法前执行
        System.out.println("----------执行前-----------");

        Object obj = method.invoke(target, args);

        //目标方法后执行
        System.out.println("----------执行后-----------");

        return obj;
    }
}
